You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactor common context struct to use newly introduced interfaces to libbuildpack functionalities in order to be able to generate mocks. The mocks are further used in supply/finalize unit tests and are generated in a similar manner to other community buildpacks.
Fix the supply phase unit tests that always passed and tested nothing. The generated mocks provide the ability to run supply phase without doing real download of dependencies.
Fixed supply test case for Tomcat container to test supply.Run(..)
Fixed supply test case for Spring Boot container to test supply.Run(..)
Fixed supply test case for Groovy container to test supply.Run(..)
Fix the finalize phase unit tests that always passed and tested nothing.
Fixed finalize test case for Tomcat container to test finalize.Run(..)
Fixed finalize test case for Spring Boot container to test finalize.Run(..)
Added finalize test case for Groovy container testing finalize.Run(..)
kiril-keranov
changed the title
Refactor common context, generate mocks, fix hollow unit tests for supply
[go-migration] Refactor common context, generate mocks, fix hollow unit tests for supply
Feb 26, 2026
kiril-keranov
changed the title
[go-migration] Refactor common context, generate mocks, fix hollow unit tests for supply
[go-migration] Refactor common context, generate mocks, fix hollow unit tests for supply/finalize
Feb 26, 2026
Bug — memCalcInstallDir directory is never created
In supply_test.go, the MkdirAll call for the memory calculator install directory uses the wrong variable:
// create memory calculator install dirmemCalcInstallDir:=filepath.Join(depsDir, depsIdx, "tmp", "memory-calculator")
Expect(os.MkdirAll(filepath.Join(jvmkillInstallDir), 0755)).To(Succeed()) // should be memCalcInstallDir
jvmkillInstallDir is used again instead of memCalcInstallDir, so the memory calculator directory is never created on disk. Since mockInstaller mocks out the actual install call, this likely won't cause a test failure today — but it's incorrect and will break if any post-install code ever tries to read from that directory.
Fix: Replace jvmkillInstallDir with memCalcInstallDir in that MkdirAll call.
Minor — Dead Installer interface in cf_metrics_exporter.go
After this PR removes the installer Installer field from CfMetricsExporterFramework, the local Installer interface defined at the top of cf_metrics_exporter.go is no longer referenced anywhere and can be removed.
Low — github.com/golang/mock is archived
github.com/golang/mock v1.6.0 was officially archived in June 2023 and receives no further updates or security fixes. The community-maintained fork go.uber.org/mock has an identical API and would be a better long-term choice. Not a blocker, but worth considering before this becomes harder to migrate.
Observation — Finalize tests are a hybrid integration/unit style
The finalize tests set finalizer.JREName directly and use a real libbuildpack.Stager alongside the mocked manifest/installer. This means jre.Finalize() (called via resolveJRE()) will perform real filesystem writes through the stager. This isn't a bug, but the mixed approach can obscure what's actually being unit tested vs. integration tested.
Observation — No test for the "no recognized application type" error path
Now that supply.Run() is testable via mocks, a test covering the case where no container is detected (→ Run() returns an error) would be straightforward to add and fills a meaningful gap that was previously only noted in a comment pointing to integration tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The PR introduces the following changes:
contextstruct to use newly introduced interfaces to libbuildpack functionalities in order to be able to generate mocks. The mocks are further used in supply/finalize unit tests and are generated in a similar manner to other community buildpacks.supplyphase unit tests that always passed and tested nothing. The generated mocks provide the ability to run supply phase without doing real download of dependencies.supply.Run(..)supply.Run(..)supply.Run(..)finalizephase unit tests that always passed and tested nothing.finalize.Run(..)finalize.Run(..)finalize.Run(..)Addressing this issue
Additional change is also adjusting the
cf-metrics-exportertests